/**
 * 合同历史回款分析
 * zty
 * 2017-02-20
 */
(function () {
    var serverData = {};
    var	serverTable;
  //查询1
    jQuery("#searchBtn").on('click',function(){//按键ID
    	serverData.key=jQuery("#search").val();//文本框的ID
    	serverTable.draw();
    });
    
    //撤消
    jQuery("#reset").on('click',function(){
    	jQuery("#search").val('');//文本框的ID
    	serverData.key='';
    	serverTable.draw();
    });
    jQuery(document).ready(function () {
        serverTable = jQuery('#dataTable').DataTable({
        	"serverSide": true,
        	"ordering": false,
        	"ajax": {
        	"dataType": "json",
        	"type": "get",
        	"cache": false,
        	"url":window.rootPath+ '/ui/payHistory/getpage',
        	"data": function (d) {
        		return $.extend({}, d, serverData);
        		}
        	},
        "columns": [{
                      data: null,
                      defaultContent : ""// 排序   1
                  },
                  {
                      data: 'cCustomerName'
                  },
                  {
                      data: 'ctotalSum'
                  },
                  {
                      data: 'cprojectName'//项目名称
                  },
                  {
                      data: 'careaName'//片区
                  },
                  {
                      data: 'csPayMan'//收款责任人
                  },  
                  {
                      data: 'csPaidWay'//付款方式
                  },
                  {
                      data: 'cnPaidSum'//付款金额
                  },
                  {
                      data: 'cdPaidDate',//付款时间
                      render: function (data, type, full, meta) {
                          if (data)
                              return moment(data).format('YYYY-MM-DD');
                          else{
                              return '';
                      }
                  }
                  },
                  {
                	 data: 'csMemo'//备注
                  }],
                  "drawCallback": function (oSettings) {
                      var k = 0;
                      var total = oSettings.aiDisplay.length + oSettings._iDisplayStart;

                      for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
                          $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
                          k++;
                      }
                    
                  }
    });
    });
        
	    
})();